package com.legal.aid.app.controller;


import com.legal.aid.app.domain.vo.CaseVo;
import com.legal.aid.app.service.IAppCaseService;
import com.legal.aid.common.core.controller.BaseController;
import com.legal.aid.common.core.domain.AjaxResult;
import com.legal.aid.common.core.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/app/case")
public class AppCaseController  extends BaseController {

    @Autowired
    private IAppCaseService appCaseService;

    @GetMapping("/list")
    public TableDataInfo list(CaseVo caseVo)
    {
        startPage();
        List<CaseVo> list = appCaseService.selectCaseVo(caseVo);
        return getDataTable(list);
    }

    /**
     * 获取经典案例详细信息
     */
    @GetMapping(value = "/{caseId}")
    public AjaxResult getInfo(@PathVariable("caseId") Long caseId)
    {
        return success(appCaseService.selectCaseByCaseId(caseId));
    }

    /**
     * 获取经典案例详细信息
     */
    @GetMapping(value = "/search/{titleKey}")
    public AjaxResult searchCaseByTitle(@PathVariable("titleKey") String titleKey)
    {
        return success(appCaseService.selectCaseByCaseTitle(titleKey));
    }

    /**
     * 获取当前登录用户案列的关注列表
     *
     */
    @GetMapping("/attention")
    public AjaxResult selectAttentionCaseList()
    {
        List<CaseVo> list=appCaseService.selectAttentionCaseVoList();
        return AjaxResult.success(list);
    }
}
